import type { ToolLabelRecord } from "@/pages/tool/labelRecord/entity";
import apiClient from "../../apiClient";

export interface PageListReq {
  //产品ID
  materialId?: number;
  //标签条码
  labelCode?: string;
  //打印时间
  printTime?: Date;
  //当前页码
  page: number;
  //每页数量
  pageSize: number;
}

export interface PageListRes {
  //总记录数
  total: number;
  //数据列表
  records: ToolLabelRecord[];
}

const pageList = (data: PageListReq): Promise<PageListRes> =>
  apiClient.post({
    url: "/tool/label/record/pageList",
    data
});
const getInfo = (id: React.Key): Promise<ToolLabelRecord> =>
  apiClient.get({
    url: `/tool/label/record/${id}`
});

const add = (data: ToolLabelRecord): Promise<ToolLabelRecord> =>
  apiClient.post({
    url: "/tool/label/record",
    data
});

const update = (data: ToolLabelRecord): Promise<ToolLabelRecord> =>
  apiClient.put({
    url: "/tool/label/record",
    data
});

const remove = (ids: React.Key[]): Promise<void> =>
  apiClient.delete({
    url: "/tool/label/record",
    params: {
    ids: ids.join(",")
  }
});
export const toolLabelRecordService = {
  pageList,
  getInfo,
  add,
  update,
  remove,
};

export default toolLabelRecordService;